/* Copyright © 2010 LPRM
Universidade Federal do Espírito Santo - RNP-GT CWTools

This file is part of JoinUs!.

JoinUs! is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

JoinUs! is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with JoinUs!. If not, see <http://www.gnu.org/licenses/>. */
package br.ufes.cwtools.joinus.system_logger;

import android.app.Activity;
import br.ufes.cwtools.joinus.R;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

// Esta activity simula o comportamento de um dialog para confirmação do password.
// Referência: http://wiresareobsolete.com/wordpress/2010/01/android-dialog-or-is-it/
public class PasswordConfirmationActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.password_confirmation);
	}
	
	public void confirmOnClick(View view) {
		String password = this.getIntent().getStringExtra("password"); 
		String confirmation =
			((EditText) this.findViewById(R.id.password_confirmation))
			.getText().toString().toLowerCase();
		if (password.equals(confirmation)) {
			this.setResult(RESULT_OK);
			this.finish();
		} else {
			Toast.makeText(this, "Passwords do not match.", Toast.LENGTH_SHORT).show();
		}
	}
	
	public void cancelOnClick(View view) {
		this.setResult(RESULT_CANCELED);
		this.finish();
	}
}
